package com.pi2e.view.activity;

import org.w3c.dom.Comment;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.pi2e.R;
import com.pi2e.common.KdxfSpeechHelper;
import com.pi2e.common.KdxfSpeechHelper.SpeechCompletedListener;
import com.pi2e.view.base.BaseActivity;
import com.pi2e.view.common.FootView;
import com.pi2e.view.common.HeaderView;

public class StepIntoElevatorActivity extends BaseActivity implements OnClickListener {

	View mfootview ;
	View mHeadView ;
	
	String content = "电梯到了一起进入吧！" ;
	TextView txt_content ;
	Handler handler = new Handler() ;
	Runnable runEnd = new Runnable() {
		
		@Override
		public void run() {
			Intent it = new Intent(StepIntoElevatorActivity.this,CommentRobotActivity.class) ;
			startActivity(it);
			finish();
		}
	};
	Runnable runStart = new Runnable() {
		
		@Override
		public void run() {
			KdxfSpeechHelper.startPlay(content, new SpeechCompletedListener() {
				
				@Override
				public boolean onPreperPlay() {
					// TODO Auto-generated method stub
					return false;
				}
				
				@Override
				public boolean onPlay(String Msg) {
					// TODO Auto-generated method stub
					return false;
				}
				
				@Override
				public boolean onError() {
					// TODO Auto-generated method stub
					return false;
				}
				
				@Override
				public boolean onCompleted() {
					handler.postDelayed(runEnd, KdxfSpeechHelper.AFTER_SPEECH_DELAY_TIME) ;
					return false;
				}
			});
			
		}
	};
	private ImageView mImgLogo;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		handler.postDelayed(runStart, KdxfSpeechHelper.BEFORE_SPEECH_DELAY_TIME) ;
	}
	@Override
	public HeaderView initHeaderView() {
		HeaderView hv = new HeaderView(findViewById(R.id.headId),this) ;
		hv.getTitle_Tv().setText("");
		return hv;
	}

	@Override
	public void setContentView() {
		setContentView(R.layout.activity_guidevip);

	}

	@Override
	public void initView() {
		mfootview = findViewById(R.id.footId) ;
		mHeadView = findViewById(R.id.headId) ;
		txt_content = (TextView) findViewById(R.id.txt_guide) ;
		txt_content.setText(content);
		mImgLogo = (ImageView) findViewById(R.id.img_logo) ;
		mImgLogo.setImageResource(R.drawable.test_startrece_01);

	}

	@Override
	public void initFootView() {
		FootView footView = new FootView(StepIntoElevatorActivity.this, mfootview) ;
		footView.getBtn_ok().setText("退 出");
		footView.getBtn_ok().setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				
				finish();
			}
		});
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		
	}
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		if (null != handler && null !=runStart) {
			KdxfSpeechHelper.onDestroy();
			handler.removeCallbacks(runStart);
		}
	}

}
